// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import {router} from './router/index'
import iview from 'iview' // 引入iview组件
import 'iview/dist/styles/iview.css' // 引入iview样式
import cookies from './utils/cookie' // 引入cookie
import './style/base.css' // 公共样式
Vue.use(iview)

Vue.config.productionTip = false

/* eslint-disable no-new */
// console.log(process.env.NODE_ENV)
window.implict = {} // 全局定义一个implict对象
window.implict.cookies = cookies // 在全局对象中定义cookie的方法
new Vue({
  el: '#app',
  router,
  render: h => h(App),
  created () {
    // 定义implict
    window.implict.message = {}
    window.implict.modal = {}
    /**
     * 全局设置成功消息提示
     * @param {*} params ：提示内容
     */
    window.implict.message.success = params => {
      this.$Message.success(params)
    }
    /**
     * 全局设置错误消息提示
     * @param {*} params ：提示内容
     */
    window.implict.message.error = params => {
      this.$Message.error(params)
    }
    /**
     * 全局设置警告消息提示
     * @param {*} params ：提示内容
     */
    window.implict.message.warning = params => {
      this.$Message.warning(params)
    }
    /**
     * 全局设置成功对话框显示
     * @param {对话框标题} title
     * @param {显示内容} content
     */
    window.implict.modal.success = (title, content) => {
      this.$Modal.success({
        title: title,
        content: content
      })
    }
    /**
     * 全局设置错误对话框显示
     * @param {对话框标题} title
     * @param {显示内容} content
     */
    window.implict.modal.error = (title, content) => {
      this.$Modal.error({
        title: title,
        content: content
      })
    }
    /**
     * 全局设置消息对话框显示
     * @param {对话框标题} title
     * @param {显示内容} content
     */
    window.implict.modal.info = (title, content) => {
      this.$Modal.info({
        title: title,
        content: content
      })
    }
    /**
     * 全局设置警告对话框显示
     * @param {对话框标题} title
     * @param {显示内容} content
     */
    window.implict.modal.warning = (title, content) => {
      this.$Modal.warning({
        title: title,
        content: content
      })
    }
  },
  mounted () {
    var arr = [{a: '1', b: '2'}, {c: '1', d: '2'}]
    var newArr = []
    arr.forEach(item => {
      for (const key in item) {
        console.log(item[key])
        if (item[key] === '1') {
          newArr.push(key)
        }
      }
    })
    console.log(newArr)
  }
})
